package Test;

public class test3 {
    public static void main(String[] args) {
        int n = 3;
        char x = 'x';//起始杆
        char y = 'y';//中间杆
        char z = 'z';//目标杆
        han(x,y,z,n);


    }

    private static void han(char x, char y, char z, int n) {
        if(n==1){
            System.out.println(x+"---->"+z);
            return;
        }else{
            han(x,z,y,n-1);
            System.out.println(x+"--->"+z);
            han(y,x,z,n-1);
        }

    }


}
